package com.example.leetdemo.finash;

public class Solution258 {

    public int addDigits(int num) {
        int n = num;
        while (n > 9) {
            int temp = 0;
            while (n != 0) {
                temp += n % 10;
                n = n / 10;
            }
            n = temp;
        }
        return n;
    }

    public static void main(String[] args) {
        Solution258 solution258 = new Solution258();
        System.err.println(solution258.addDigits(22154));
    }

}
